Skip to content

The Allegro export escapes net names, and works without a GUI prompt - #161

Merged
Gherkin merged 4 commits into
mainfrom
allegro-escape-net-names
Oct 31, 2026
Merged

Gherkin merged 4 commits into
mainfrom
allegro-escape-net-names

Conversation

@Gherkin

@Gherkin Gherkin commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Fixes #160.

exportJson.il wrote net names into the JSON as they are. A net name with " or \ made the file invalid JSON.

  • New helper jsonEscape escapes \ first, then ". It also doubles %, because writeJsonFile passes each line to fprintf as the format string. The component table already doubles % for the same reason.
  • Used at every place a net name is written: tracks, arcs, vias, zones, pads and the net list.
  • Separate commit: axlUIPrompt returns nil for rev and company when run without a GUI. Both now fall back to "", so addMetadata does not fail.

Testing

🤖 Generated with Claude Code

https://claude.ai/code/session_01UCbPYsA5LYNX8HZaGGZCpK

Gherkin and others added 2 commits October 30, 2026 13:07
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCbPYsA5LYNX8HZaGGZCpK
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-31 10:44 UTC

@Gherkin

Gherkin commented Oct 31, 2026

Copy link
Copy Markdown
Owner Author

/prr round 1

Fixing:

  1. allegro-skills/exportJson.il:2933 — each line is passed to fprintf as the format string. Any field without %% doubling (text, refdes, footprint, pin, rev, company) breaks the write. Fix: fprintf( outPort "%s\n" line ), then drop the % doubling in jsonEscape and the component table.
  2. allegro-skills/exportJson.il:25 — rev, company and design name are quoted but not escaped. Fix: jsonEscape.
  3. allegro-skills/exportJson.il:347 — board text escapes " only, not \. Fix: jsonEscape.
  4. allegro-skills/exportJson.il:1624 — pin number escapes " only. Fix: jsonEscape.
  5. allegro-skills/exportJson.il:1700 — component table: value lacks \ escape; footprint, refdes, property key unescaped (:1737, :1760, :1762). Fix: jsonEscape.

FYI, not fixing:

  1. allegro-skills/exportJson.il:68 — pcreCompile three times per call, per segment/via/pad. Not measured; the issue reports a ~16k pad board exports fine.
  2. allegro-skills/exportJson.il:70 — control characters (tab etc.) are not escaped. Unlikely in Allegro names; left out.
  3. allegro-skills/exportJson.il:14 — rev/company prompt repeats once per variant. Older behaviour, not from this PR.
  4. allegro-skills/exportJson.il:2941 — axlUIConfirm in the error paths still needs a GUI. Older code. The axlUIPrompt nil return was seen in a real no-GUI run (per Allegro export writes invalid JSON when a net name contains " or \ #160), so the new comment stands.

None of this is runnable here; no test runs the SKILL script.

…y string field

fprintf no longer reads output lines as its format, so % needs no doubling. jsonEscape now also covers metadata, board text, pin numbers, and the component table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01UCbPYsA5LYNX8HZaGGZCpK
@Gherkin

Gherkin commented Oct 31, 2026

Copy link
Copy Markdown
Owner Author

/prr round 2 (56ded7c..531be4d)

Fixing:

  1. allegro-skills/exportJson.il:1916 — footprint ref is written raw; the component table escapes the same refdes. Fix: jsonEscape.
  2. allegro-skills/exportJson.il:2789 — inner layer names go into tracks/zones keys unescaped. Fix: jsonEscape.

FYI, not fixing:

  1. allegro-skills/exportJson.il:1691 — jsonEscape on a numeric VALUE property would error in pcreReplace. The old code called pcreReplace on it too, so not new. Converting numbers means picking a format.
  2. allegro-skills/exportJson.il:1727 — property key comes from sprintf "%L", which may add SKILL escapes. Older code; this commit makes it valid JSON where it was invalid. Cannot check %L output without Allegro.
  3. allegro-skills/exportJson.il:67 — control characters not escaped. Same as round 1 item 7.
  4. allegro-skills/exportJson.il:69 — two pcreCompile per call. Same as round 1 item 6.
  5. allegro-skills/exportJson.il:1747 — one jsonString helper that quotes and escapes would stop missed sites. Larger refactor; not for this PR.

None of this is runnable here; no test runs the SKILL script.

Both were still written raw after jsonEscape was applied to the other string fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01UCbPYsA5LYNX8HZaGGZCpK
@Gherkin
Gherkin merged commit c22f2e8 into main Oct 31, 2026
10 checks passed
@Gherkin
Gherkin deleted the allegro-escape-net-names branch October 31, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allegro export writes invalid JSON when a net name contains " or \

1 participant